﻿@using Abp.Extensions
@using AbpZeroTemplate.MultiTenancy
@using AbpZeroTemplate.Web.Areas.AppAreaName.Models.Common.Modals
@using AbpZeroTemplate.Web.Areas.AppAreaName.Models.Tenants
@model EditTenantViewModel

@Html.Partial("~/Areas/AppAreaName/Views/Common/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(L("EditTenant") + ": " + Model.Tenant.TenancyName))

<div class="modal-body">

    <form name="TenantInformationsForm">

        <input type="hidden" name="Id" value="@Model.Tenant.Id" />
        <input type="hidden" name="TenancyName" value="@Model.Tenant.TenancyName" />

        <div class="form-group">
            <label for="Name">@L("Name")</label>
            <input id="Name" type="text" name="Name" value="@Model.Tenant.Name" class="form-control edited" required maxlength="@Tenant.MaxNameLength">
        </div>

        @if (!Model.Tenant.ConnectionString.IsNullOrEmpty())
        {
            <div class="form-group">
                <label for="ConnectionString">@L("DatabaseConnectionString")</label>
                <input id="ConnectionString" type="text" name="ConnectionString" class="form-control edited" value="@Model.Tenant.ConnectionString" required maxlength="@Tenant.MaxConnectionStringLength">
            </div>

            <div>
                <span class="help-block text-warning">@L("TenantDatabaseConnectionStringChangeWarningMessage")</span>
            </div>
        }

        <div class="form-group">
            <label for="EditionId">@L("Edition")</label>
            <select class="form-control" id="EditionId" name="EditionId">
                @foreach (var edition in Model.EditionItems)
                {
                    <option value="@edition.Value" data-isfree="@edition.IsFree" selected="@edition.IsSelected">@edition.DisplayText</option>
                }
            </select>
        </div>
        
        <div class="m-checkbox-list subscription-component">
            <label class="m-checkbox">
                <input id="CreateTenant_IsUnlimited" type="checkbox" name="IsUnlimited" @(!Model.Tenant.SubscriptionEndDateUtc.HasValue ? "checked=\"checked\"" : "") />
                @L("UnlimitedTimeSubscription")
                <span></span>
            </label>
        </div>
        
        <div class="form-group subscription-component">
            <label for="SubscriptionEndDateUtc">@L("SubscriptionEndDateUtc")</label>
            <input id="SubscriptionEndDateUtc" type="datetime" name="SubscriptionEndDateUtc" value="@(Model.Tenant.SubscriptionEndDateUtc?.ToString("yyyy-MM-dd"))" class="form-control edited date-time-picker" @(!Model.Tenant.SubscriptionEndDateUtc.HasValue ? "required" : "")>
        </div>
        
        <div class="m-checkbox-list subscription-component">
            <label class="m-checkbox">
                <input id="EditTenant_IsInTrialPeriod" type="checkbox" name="IsInTrialPeriod" value="true" @(Model.Tenant.IsInTrialPeriod ? "checked=\"checked\"" : "") />
                @L("IsInTrialPeriod")
                <span></span>
            </label>
        </div>
        
        <div class="m-checkbox-list">
            <label class="m-checkbox">
                <input id="EditTenant_IsActive" type="checkbox" name="IsActive" value="true" @Html.Raw(Model.Tenant.IsActive ? "checked=\"checked\"" : "")>
                @L("Active")
                <span></span>
            </label>
        </div>

    </form>

</div>

@Html.Partial("~/Areas/AppAreaName/Views/Common/Modals/_ModalFooterWithSaveAndCancel.cshtml")